<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

  <title>Module: Analytics::Database</title>

  <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />

  <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>

</head>
<body id="top" class="module">

  <div id="metadata">
    <div id="home-metadata">
      <div id="home-section" class="section">
        <h3 class="section-header">
          <a href="../index.html">Home</a>
          <a href="../index.html#classes">Classes</a>
          <a href="../index.html#methods">Methods</a>
        </h3>
      </div>
    </div>

    <div id="file-metadata">
      <div id="file-list-section" class="section">
        <h3 class="section-header">In Files</h3>
        <div class="section-body">
          <ul>
          
            <li><a href="../lib/graph_controller_extensions/database_analytics_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
              class="thickbox" title="lib/graph_controller_extensions/database_analytics.rb">lib/graph_controller_extensions/database_analytics.rb</a></li>
          
          </ul>
        </div>
      </div>

      
    </div>

    <div id="class-metadata">
      

      

      

      
      <!-- Method Quickref -->
      <div id="method-list-section" class="section">
        <h3 class="section-header">Methods</h3>
        <ul class="link-list">
          
          <li><a href="#method-i-get_database_data">#get_database_data</a></li>
          
          <li><a href="#method-i-get_database_usage_graph">#get_database_usage_graph</a></li>
          
          <li><a href="#method-i-get_percentage_db_usage_data">#get_percentage_db_usage_data</a></li>
          
          <li><a href="#method-i-percentage_time_spent_in_db_layer">#percentage_time_spent_in_db_layer</a></li>
          
        </ul>
      </div>
      

      
    </div>

    <div id="project-metadata">
      
      
      <div id="fileindex-section" class="section project-section">
        <h3 class="section-header">Files</h3>
        <ul>
        
          <li class="file"><a href="../doc/README_FOR_APP.html">README_FOR_APP</a></li>
        
        </ul>
      </div>
      

      <div id="classindex-section" class="section project-section">
        <h3 class="section-header">Class/Module Index
          <span class="search-toggle"><img src="../images/find.png"
            height="16" width="16" alt="[+]"
            title="show/hide quicksearch" /></span></h3>
        <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
        <fieldset>
          <legend>Quicksearch</legend>
          <input type="text" name="quicksearch" value=""
            class="quicksearch-field" />
        </fieldset>
        </form>

        <ul class="link-list">
        
          <li><a href="../Analytics.html">Analytics</a></li>
        
          <li><a href="../Analytics/Database.html">Analytics::Database</a></li>
        
          <li><a href="../Analytics/ResourceUsage.html">Analytics::ResourceUsage</a></li>
        
          <li><a href="../Analytics/Throughput.html">Analytics::Throughput</a></li>
        
          <li><a href="../Analytics/Url.html">Analytics::Url</a></li>
        
          <li><a href="../Analytics/UrlBreakup.html">Analytics::UrlBreakup</a></li>
        
          <li><a href="../ActionView.html">ActionView</a></li>
        
          <li><a href="../ActionView/Helpers.html">ActionView::Helpers</a></li>
        
          <li><a href="../ActionView/Helpers/AssetTagHelper.html">ActionView::Helpers::AssetTagHelper</a></li>
        
          <li><a href="../AdminController.html">AdminController</a></li>
        
          <li><a href="../AdminHelper.html">AdminHelper</a></li>
        
          <li><a href="../App.html">App</a></li>
        
          <li><a href="../AppException.html">AppException</a></li>
        
          <li><a href="../AppTimeSample.html">AppTimeSample</a></li>
        
          <li><a href="../ApplicationController.html">ApplicationController</a></li>
        
          <li><a href="../ApplicationHelper.html">ApplicationHelper</a></li>
        
          <li><a href="../ApplicationSpecification.html">ApplicationSpecification</a></li>
        
          <li><a href="../ApplicationSpecificationController.html">ApplicationSpecificationController</a></li>
        
          <li><a href="../ApplicationSpecificationHelper.html">ApplicationSpecificationHelper</a></li>
        
          <li><a href="../Control.html">Control</a></li>
        
          <li><a href="../ExceptionDetail.html">ExceptionDetail</a></li>
        
          <li><a href="../ExceptionsController.html">ExceptionsController</a></li>
        
          <li><a href="../ExceptionsHelper.html">ExceptionsHelper</a></li>
        
          <li><a href="../GraphController.html">GraphController</a></li>
        
          <li><a href="../GraphHelper.html">GraphHelper</a></li>
        
          <li><a href="../Headers.html">Headers</a></li>
        
          <li><a href="../HeadersController.html">HeadersController</a></li>
        
          <li><a href="../HeadersHelper.html">HeadersHelper</a></li>
        
          <li><a href="../MailSpecification.html">MailSpecification</a></li>
        
          <li><a href="../MailSpecificationController.html">MailSpecificationController</a></li>
        
          <li><a href="../MailSpecificationHelper.html">MailSpecificationHelper</a></li>
        
          <li><a href="../Mailer.html">Mailer</a></li>
        
          <li><a href="../Object.html">Object</a></li>
        
          <li><a href="../PseudoModel.html">PseudoModel</a></li>
        
          <li><a href="../ResourceUsage.html">ResourceUsage</a></li>
        
          <li><a href="../SCGI.html">SCGI</a></li>
        
          <li><a href="../ServerSpecification.html">ServerSpecification</a></li>
        
          <li><a href="../ServerSpecificationController.html">ServerSpecificationController</a></li>
        
          <li><a href="../ServerSpecificationHelper.html">ServerSpecificationHelper</a></li>
        
          <li><a href="../SignalHelper.html">SignalHelper</a></li>
        
          <li><a href="../UrlBreakupTimeSample.html">UrlBreakupTimeSample</a></li>
        
          <li><a href="../UrlTimeSample.html">UrlTimeSample</a></li>
        
          <li><a href="../User.html">User</a></li>
        
          <li><a href="../YAMLConfig.html">YAMLConfig</a></li>
        
          <li><a href="../YAMLWriter.html">YAMLWriter</a></li>
        
        </ul>
        <div id="no-class-search-results" style="display: none;">No matching classes.</div>
      </div>

      
    </div>
  </div>

  <div id="documentation">
    <h1 class="module">Analytics::Database</h1>

    <div id="description" class="description">
      
    </div><!-- description -->

    
    
    
    <div id="5Buntitled-5D" class="documentation-section">
      

      

      

      

      <!-- Methods -->
      
      <div id="public-instance-method-details" class="method-section section">
        <h3 class="section-header">Public Instance Methods</h3>

      
        <div id="get_database_data-method" class="method-detail ">
          <a name="method-i-get_database_data"></a>

          
          <div class="method-heading">
            <span class="method-name">get_database_data</span><span
              class="method-args">(app_id)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This method renders the partial containing <a
href="Database.html">Database</a> Usage Graphs.</p>
            

            
            <div class="method-source-code" id="get_database_data-source">
<pre>
<span class="ruby-comment"># File lib/graph_controller_extensions/database_analytics.rb, line 33</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_database_data</span>(<span class="ruby-identifier">app_id</span>)
  <span class="ruby-ivar">@app_id</span> = <span class="ruby-identifier">app_id</span>
  <span class="ruby-identifier">check_and_set_query_date</span> 
  <span class="ruby-identifier">start_date</span> = <span class="ruby-identifier">session</span>[<span class="ruby-value">:start_time</span>].<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&quot;%Y-%m-%d&quot;</span>)<span class="ruby-operator">+</span><span class="ruby-string">&quot; 00:00:00&quot;</span>
  <span class="ruby-identifier">end_date</span> = <span class="ruby-identifier">session</span>[<span class="ruby-value">:start_time</span>].<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&quot;%Y-%m-%d&quot;</span>)<span class="ruby-operator">+</span><span class="ruby-string">&quot; 23:59:59&quot;</span>
  <span class="ruby-identifier">urls</span> = <span class="ruby-constant">UrlTimeSample</span>.<span class="ruby-identifier">get_urls</span>(<span class="ruby-identifier">start_date</span>, <span class="ruby-identifier">end_date</span>, <span class="ruby-identifier">app_id</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">urls</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>            
    <span class="ruby-ivar">@percentage_db_usage_graph</span> = <span class="ruby-identifier">get_database_usage_graph</span>(<span class="ruby-ivar">@app_id</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-constant">NO_DATA_FOUND</span>
  <span class="ruby-keyword">end</span>      
  <span class="ruby-identifier">render</span> <span class="ruby-value">:partial</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'database_usage_graph'</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- get_database_data-source -->
            
          </div>

          

          
        </div><!-- get_database_data-method -->

      
        <div id="get_database_usage_graph-method" class="method-detail ">
          <a name="method-i-get_database_usage_graph"></a>

          
          <div class="method-heading">
            <span class="method-name">get_database_usage_graph</span><span
              class="method-args">(app_id)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This method is to populate the varriable graph4 and graph9 with the
respective graphs data. graph4 contains the data for the Percentage time
spent in database layer graph. graph9 contains the data for the Top
database consuming urls graph.</p>
            

            
            <div class="method-source-code" id="get_database_usage_graph-source">
<pre>
<span class="ruby-comment"># File lib/graph_controller_extensions/database_analytics.rb, line 27</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_database_usage_graph</span>(<span class="ruby-identifier">app_id</span>)
<span class="ruby-ivar">@start_hour</span>, <span class="ruby-ivar">@end_hour</span>, <span class="ruby-identifier">start_time</span>, <span class="ruby-identifier">end_time</span> = <span class="ruby-identifier">get_start_and_end_time_from_session</span>()    
  <span class="ruby-identifier">percentage_db_usage_graph</span> = <span class="ruby-identifier">plot_graph</span>(<span class="ruby-node">&quot;graph/get_percentage_db_usage_data/#{app_id}?time_slab=#{start_time}.#{end_time}&quot;</span>, <span class="ruby-string">'percentage_db_usage'</span>)<span class="ruby-comment">#Graph depicts the % database usage     </span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- get_database_usage_graph-source -->
            
          </div>

          

          
        </div><!-- get_database_usage_graph-method -->

      
        <div id="get_percentage_db_usage_data-method" class="method-detail ">
          <a name="method-i-get_percentage_db_usage_data"></a>

          
          <div class="method-heading">
            <span class="method-name">get_percentage_db_usage_data</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This method is used to get the data for percentage db usage from the <a
href="../AppTimeSample.html">AppTimeSample</a> model. This data is supplied
to the bar_grap method to plot the line graph.</p>
            

            
            <div class="method-source-code" id="get_percentage_db_usage_data-source">
<pre>
<span class="ruby-comment"># File lib/graph_controller_extensions/database_analytics.rb, line 62</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_percentage_db_usage_data</span>
  <span class="ruby-identifier">start_time</span>,<span class="ruby-identifier">end_time</span> = <span class="ruby-identifier">get_time_range</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:time_slab</span>])
  <span class="ruby-identifier">app_id</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value">:id</span>]
  <span class="ruby-identifier">wall_time</span>, <span class="ruby-identifier">db_time</span>, <span class="ruby-identifier">max</span>, <span class="ruby-identifier">slab</span>, <span class="ruby-identifier">step</span> = <span class="ruby-constant">AppTimeSample</span>.<span class="ruby-identifier">get_application_data</span>(<span class="ruby-identifier">app_id</span>, <span class="ruby-identifier">start_time</span>, <span class="ruby-identifier">end_time</span>, <span class="ruby-string">&quot;db&quot;</span>)
  <span class="ruby-identifier">line_graph</span>(<span class="ruby-identifier">wall_time</span>, <span class="ruby-identifier">db_time</span>, <span class="ruby-constant">PERCENTAGE_TIME_SPENT_IN_DATABASE_LAYER_GRAPH_TITLE</span>, <span class="ruby-identifier">max</span>, <span class="ruby-identifier">slab</span>, <span class="ruby-identifier">step</span>, <span class="ruby-string">&quot;Wall Time&quot;</span>, <span class="ruby-string">&quot;% Time Spent&quot;</span>)
<span class="ruby-keyword">end</span></pre>
            </div><!-- get_percentage_db_usage_data-source -->
            
          </div>

          

          
        </div><!-- get_percentage_db_usage_data-method -->

      
        <div id="percentage_time_spent_in_db_layer-method" class="method-detail ">
          <a name="method-i-percentage_time_spent_in_db_layer"></a>

          
          <div class="method-heading">
            <span class="method-name">percentage_time_spent_in_db_layer</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This method is called for getting the percentage time spent graph for a
specific date and time.</p>
            

            
            <div class="method-source-code" id="percentage_time_spent_in_db_layer-source">
<pre>
<span class="ruby-comment"># File lib/graph_controller_extensions/database_analytics.rb, line 48</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">percentage_time_spent_in_db_layer</span>
    <span class="ruby-identifier">app_id</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value">:app_id</span>]
          <span class="ruby-identifier">time_array</span> = <span class="ruby-identifier">get_start_end_time</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:date</span>], <span class="ruby-identifier">params</span>[<span class="ruby-value">:start_time</span>], <span class="ruby-identifier">params</span>[<span class="ruby-value">:end_time</span>])
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">time_array</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
        <span class="ruby-ivar">@percentage_db_usage_graph</span> = <span class="ruby-identifier">plot_graph</span>(<span class="ruby-node">&quot;graph/get_percentage_db_usage_data/#{app_id}?time_slab=#{time_array[0]}.#{time_array[1]}&quot;</span>, <span class="ruby-string">'percentage_db_usage'</span>)
       <span class="ruby-identifier">render</span> <span class="ruby-value">:text</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@percentage_db_usage_graph</span>
    <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">render</span> <span class="ruby-value">:text</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">time_array</span>[<span class="ruby-value">0</span>]
    <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- percentage_time_spent_in_db_layer-source -->
            
          </div>

          

          
        </div><!-- percentage_time_spent_in_db_layer-method -->

      
      </div><!-- public-instance-method-details -->
    
    </div><!-- 5Buntitled-5D -->
  

  </div><!-- documentation -->

  <div id="validator-badges">
    <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
    <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
      Rdoc Generator</a> 2</small>.</p>
  </div>

</body>
</html>

